package main

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"

	"rank/internal/app"
)

var version = "No Build Info"

func main() {
	srv, err := app.New(
		app.Config(),
		app.Version(version),
		app.Logger(),
		app.RedisCli(),
		app.Dao(),
		app.WebService(),
	)

	defer func() {
		if err != nil {
			_, _ = fmt.Fprintln(os.Stderr, err.Error())
		}
	}()

	if err != nil {
		return
	}

	ch := make(chan os.Signal, 1)
	signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
	err = srv.Run(ch)
	<-ch

	err = srv.Stop()
}
